#ifndef CART_H
#define CART_H

#include <map>
#include <string>

#include "Stock.h"
#include "TransactionIO.h"

using std::map;
using std::string;

class Cart
{
public:
	//Constructors

	//Create a TransactionIO when the cart is created
	Cart(string transactionLocation);

	//Member Functions

	/* Hold the selected item with quantity specified for the customer
	   and then set up a record for this particular item */
	bool purchaseItem(Stock* thisStock, string itemID, int quantity); //True for success; False for failure

	//Edit the quantity of a particular item stored in the cart
	bool editQuantity(Stock* thisStock, string itemID, int newQuantity); //True for success; False for failure

	//Remove the record of a particular item and put back the item in the stock
	void removeItem(Stock* thisStock, string itemID);

	//Display all records which currently stored in the cart
	void printAllRecords(Stock* thisStock);

	//Display the record detail of a particular item
	void printARecord(Stock* thisStock, string itemID);

	//Confirm the payment and produce invoice
	void checkOut(Stock* thisStock);

	//Restock the items which has not been paid
	void restockUnpaid(Stock* thisStock);

	//Destructors

	//Delete the TransactionIO when the cart is deleted
	~Cart();

private:
	//Data Members
	map<string, int> holdingItems;
	map<string, int>::iterator cartIterator;
	TransactionIO* transactionHandler;
};

#endif